100 REM --------------------------------------------------------------------
110 REM FILE NAME        BARLINE.BAS
120 REM WRITTEN BY       GARY PEEK
130 REM LAST UPDATE      10/22/87
140 REM
150 REM --------------------------------------------------------------------
160 REM RES=SMALLEST DEGREE OF CHANGE BETWEEN BAR VALUES
170 REM HEIGHT=HEIGHT IN PIXELS OF SMALLEST DEGREE OF CHANGE
180 REM MARKS=HOW MANY VALUES BETWEEN VALUE NUMBERS - USUALLY 4 OR 5 TIMES RES
190 REM REFLINE=VALUE NUMBER DISPLAYED ON LOWEST LINE
200 RES = 5: HEIGHT = 5: REFLINE = 80
210 IF RES MOD 2 = 0 THEN MARKS = RES * 5
220 IF RES MOD 3 = 0 THEN MARKS = RES * 6
230 IF RES MOD 5 = 0 THEN MARKS = RES * 4
240 COLOUR = -1: PALLET = 1
250 CLS : KEY OFF: FOR A = 1 TO 10: KEY A, "": NEXT
260 BV = REFLINE: DIM MARKET(100)
270 FOR PERIOD = 1 TO 81: A = INT(RND * (2))
280 IF A = 0 THEN BV = BV - RES
290 IF A = 1 THEN BV = BV + RES
300 MARKET(PERIOD) = BV
310 NEXT PERIOD
320 CLS
500 IF COLOUR THEN SCREEN 1: COLOR , , PALLET: GOSUB 2000: REM DRAW COLOR BARS
510 IF COLOUR = 0 THEN SCREEN 2: GOSUB 3000: REM DRAW HI-RES BARS
520 GOSUB 4000: REM CHECK FOR AND PROCESS DATA COMING IN
530 GOSUB 1000: REM CHECK FOR AND PROCESS A KEY STRUCK
540 IF UPDATE THEN UPDATE = 0: GOTO 500 ELSE GOTO 520
990 REM -------------------------- KEY STRUCK -----------------------------
1000 IN$ = INKEY$: IF IN$ = "" THEN RETURN
1010 IF IN$ = CHR$(0) + CHR$(72) THEN GOSUB 1110: GOTO 1090: REM UP
1020 IF IN$ = CHR$(0) + CHR$(80) THEN GOSUB 1130: GOTO 1090: REM DOWN
1030 IF IN$ = CHR$(0) + CHR$(75) THEN GOSUB 1170: GOTO 1090: REM LEFT
1040 IF IN$ = CHR$(0) + CHR$(77) THEN GOSUB 1190: GOTO 1090: REM RIGHT
1050 IF IN$ = CHR$(0) + CHR$(73) THEN GOSUB 1210: GOTO 1090: REM PAGE UP
1060 IF IN$ = CHR$(0) + CHR$(81) THEN GOSUB 1230: GOTO 1090: REM PAGE DOWN
1070 IF IN$ = CHR$(0) + CHR$(71) THEN GOSUB 1280: GOTO 1090: REM HOME
1080 IF IN$ = CHR$(0) + CHR$(79) THEN GOSUB 1300: GOTO 1090: REM END
1090 RETURN
1100 REM -----
1110 REFLINE = REFLINE + MARKS: UPDATE = -1: RETURN
1120 REM -----
1130 IF REFLINE <= 0 THEN BEEP: UPDATE = 0: RETURN
1140 REFLINE = REFLINE - MARKS: UPDATE = -1: RETURN
1150 REM -----
1160 REM -----
1170 REM RETURN
1180 REM -----
1190 REM RETURN
1200 REM -----
1210 COLOUR = 0: UPDATE = -1: RETURN
1220 REM -----
1230 IF COLOUR = 0 THEN COLOUR = -1: UPDATE = -1: RETURN
1240 IF PALLET = 1 THEN PALLET = 0: GOTO 1260
1250 IF PALLET = 0 THEN PALLET = 1: GOTO 1260
1260 COLOR , , PALLET: UPDATE = 0: RETURN
1270 REM -----
1280 REM RETURN
1290 REM -----
1300 SCREEN 2: END
1980 REM -------------------------------------------------------------------
1990 REM --------------------- COLOR BAR ROUTINES --------------------------
2000 TB = 0: BB = 179: LB = 50: RB = 307: WID = 3
2010 REM
2020 REM ----- DRAW BORDERS AND REFERENCE MARKS -----
2030 LINE (LB + 2, TB + 1)-(RB - 2, BB - 1), 0, BF: REM CLEAR CHART
2040 LINE (LB, TB)-(RB, BB), , B: REM BORDERS
2050 LINE (LB + 1, TB + 1)-(LB + 1, BB): LINE (RB - 1, TB)-(RB - 1, BB)
2060 FOR ROW = BB TO TB STEP -HEIGHT: REM HORIZONTAL LINES
2070 LINE (LB + 1, ROW)-(RB - 2, ROW)
2080 NEXT ROW
2090 REFNUM = REFLINE: REM HORIZONTAL MARKS AND REFERENCE NUMBERS
2100 FOR ROW = BB TO TB STEP -(MARKS / RES) * HEIGHT
2110 LINE (LB - 15, ROW)-(LB - 3, ROW)
2120 RR = INT((ROW + 8) / 8): CC = 1: LOCATE RR, CC: PRINT REFNUM;
2130 REFNUM = REFNUM + MARKS
2140 NEXT ROW
2150 FOR BAR = 4 TO 76 STEP 6: REM HALF HOUR MARKS
2160 COL = (BAR * WID) + LB + 5
2170 LINE (COL, BB + 2)-(COL + 1, BB + 4), , BF
2180 NEXT BAR
2190 HOUR = 9: REM ONE HOUR MARKS
2200 FOR BAR = 10 TO 70 STEP 12
2210 COL = (BAR * WID) + LB + 5
2220 LINE (COL, BB + 2)-(COL + 1, BB + 7), , BF
2230 CC = INT((COL + 8) / 8) - 1: RR = 25: LOCATE RR, CC: PRINT HOUR;
2240 HOUR = HOUR + 1: IF HOUR = 13 THEN HOUR = 1
2250 NEXT BAR
2260 REM
2270 REM ---- DRAW BARS -----
2280 FOR BAR = 1 TO 81
2290 BARVALUE = MARKET(BAR)
2300 COL = (BAR * WID) + LB + 5
2310 LV = (BARVALUE - REFLINE) * (HEIGHT / RES): IF LV < 0 THEN LV = 0
2320 IF COL MOD 2 = 1 THEN LINE (COL, BB)-(COL + 1, BB - LV), 1, BF
2330 IF COL MOD 2 = 0 THEN LINE (COL, BB)-(COL + 1, BB - LV), 2, BF
2340 LINE (COL + 2, BB)-(COL + 2, BB - LV), 0, BF
2350 LINE (COL - 1, BB)-(COL - 1, BB - LV), 0, BF
2360 NEXT BAR
2370 RETURN
2990 REM --------------------- HI-RES BAR ROUTINES -------------------------
3000 TB = 0: BB = 179: LB = 50: RB = 639: WID = 7
3010 REM
3020 REM ----- DRAW BORDERS AND REFERENCE MARKS -----
3030 LINE (LB + 2, TB + 1)-(RB - 2, BB - 1), 0, BF: REM CLEAR CHART
3040 LINE (LB, TB)-(RB, BB), , B: REM BORDERS
3050 LINE (LB + 1, TB + 1)-(LB + 1, BB): LINE (RB - 1, TB)-(RB - 1, BB)
3060 FOR ROW = BB TO TB STEP -HEIGHT: REM HORIZONTAL LINES
3070 LINE (LB + 1, ROW)-(RB - 2, ROW)
3080 NEXT ROW
3090 REFNUM = REFLINE: REM HORIZONTAL MARKS AND REFERENCE NUMBERS
3100 FOR ROW = BB TO TB STEP -(MARKS / RES) * HEIGHT
3110 LINE (LB - 15, ROW)-(LB - 3, ROW)
3120 RR = INT((ROW + 8) / 8): CC = 1: LOCATE RR, CC: PRINT REFNUM;
3130 REFNUM = REFNUM + MARKS
3140 NEXT ROW
3150 FOR BAR = 4 TO 76 STEP 6: REM HALF HOUR MARKS
3160 COL = (BAR * 7) + LB + 5
3170 LINE (COL + 1, BB + 2)-(COL + 3, BB + 4), , BF
3180 NEXT BAR
3190 HOUR = 9: REM ONE HOUR MARKS
3200 FOR BAR = 10 TO 70 STEP 12
3210 COL = (BAR * 7) + LB + 5
3220 LINE (COL + 1, BB + 2)-(COL + 3, BB + 7), , BF
3230 CC = INT((COL + 8) / 8) - 1: RR = 25: LOCATE RR, CC: PRINT HOUR;
3240 HOUR = HOUR + 1: IF HOUR = 13 THEN HOUR = 1
3250 NEXT BAR
3260 REM
3270 REM ----- DRAW BARS -----
3280 FOR BAR = 1 TO 81
3290 BARVALUE = MARKET(BAR)
3300 COL = (BAR * 7) + LB + 5
3310 LV = (BARVALUE - REFLINE) * (HEIGHT / RES): IF LV < 0 THEN LV = 0
3320 LINE (COL, BB)-(COL + 4, BB - LV), , BF
3330 IF COL MOD 2 = 0 THEN LINE (COL + 2, BB)-(COL + 2, BB - LV), 0, BF
3340 LINE (COL + 5, BB)-(COL + 6, BB - LV), 0, BF
3350 LINE (COL - 1, BB)-(COL - 2, BB - LV), 0, BF
3360 NEXT BAR
3370 RETURN
3990 REM -------------------- CHECK FOR DATA COMING IN --------------------
4000 REM IF DATA THEN STORE IT IN ARRAY AND GOSUB 500:RETURN
4010 RETURN

